package com.yk.airline.model;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;

/**
 * Project Name:airlinecrawler
 * File Name:CityModel
 * Package Name:com.yk.airline.model
 * Date:2018/2/1 17:47
 * Author:zhangshaoyang
 * Description:
 * Copyright (c) 2018, 重庆云凯科技有限公司 All Rights Reserved.
 */
@Entity
@Table(name = "city", schema = "cykspider", catalog = "")
public class CityModel {
    private int id;
    private String name;
    private String abbreviate;
    private Timestamp createTime;
    private Timestamp updateTime;
    private Collection<AirLineModel> airLinesById;

    @GeneratedValue(strategy = GenerationType.AUTO)
    @Id
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name", nullable = true, length = 50)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "abbreviate", nullable = true, length = 50)
    public String getAbbreviate() {
        return abbreviate;
    }

    public void setAbbreviate(String abbreviate) {
        this.abbreviate = abbreviate;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time", nullable = true)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }


    @OneToMany(mappedBy = "cityByOriginPlace")
    public Collection<AirLineModel> getAirLinesById() {
        return airLinesById;
    }

    public void setAirLinesById(Collection<AirLineModel> airLinesById) {
        this.airLinesById = airLinesById;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CityModel cityModel = (CityModel) o;

        if (id != cityModel.id) return false;
        if (name != null ? !name.equals(cityModel.name) : cityModel.name != null) return false;
        if (abbreviate != null ? !abbreviate.equals(cityModel.abbreviate) : cityModel.abbreviate != null) return false;
        if (createTime != null ? !createTime.equals(cityModel.createTime) : cityModel.createTime != null) return false;
        if (updateTime != null ? !updateTime.equals(cityModel.updateTime) : cityModel.updateTime != null) return false;
        return airLinesById != null ? airLinesById.equals(cityModel.airLinesById) : cityModel.airLinesById == null;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (abbreviate != null ? abbreviate.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        result = 31 * result + (airLinesById != null ? airLinesById.hashCode() : 0);
        return result;
    }
}
